home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 January / macformat-020.iso / Shareware City / Developers / apps.to.go / pbClock / WallToWallDialog.WDEF.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-29  |  2.3 KB  |  81 lines  |  [TEXT/MPS ]

  1. #include <Types.h>
  2. #include <Memory.h>
  3. #include <SetUpA4.h>
  4. #include <QuickDraw.h>
  5.  
  6. /* This WDEF is almost too simple.  First, call through to the normal system WDEF
  7. ** for all messages.  This includes the wCalcRgns message.  After coming back
  8. ** from the system WDEF, we know that the regions aren't as we want.  Inset the
  9. ** structure region a bit to get rid of the stupid 3-pixel white border.
  10. ** That's it. */
  11.  
  12. typedef pascal long    (*WDEFProcPtr)(short sel, WindowPeek wnd, short msg, long prm);
  13.  
  14.  
  15.  
  16. /*****************************************************************************/
  17.  
  18.  
  19.  
  20. pascal long    main(short sel, WindowPeek wnd, short msg, long prm)
  21. {
  22. #pragma unused (sel, prm)
  23.  
  24.     char            hstate;
  25.     long            keepA4, ll;
  26.     RgnHandle        srgn, crgn;
  27.     short            sleft, cleft;
  28.     WDEFProcPtr        proc;
  29.     GrafPtr            wm;
  30.     RgnHandle        wmVis;
  31.     static Handle    sysWDEF;
  32.  
  33.     RememberA0();
  34.     SetUpA4();
  35.  
  36.     if (!sysWDEF) sysWDEF = GetResource('WDEF', 0);
  37.         /* If we don't have it yet, go get a reference to the system WDEF.  We are actually
  38.         ** being extra paranoid here, as the only reason that we should keep a reference is
  39.         ** that somebody else in our resource chain may have a 'WDEF' id #0.  After the
  40.         ** window is created (maybe it is created once, and then shown and hidden), the
  41.         ** resource chain could be changed.  Therefore we get a reference the first time
  42.         ** we are called.  The user either:
  43.         ** 1) Doesn't care, because they don't play goofy resource games.
  44.         ** 2) The user cares, so they should create one of these windows early on so that
  45.         **    the reference is cached.  They can then play goofy resource games.
  46.         */
  47.  
  48.     if (msg == wDraw) {
  49.         GetPort(&wm);
  50.         CopyRgn(wm->visRgn, wmVis = NewRgn());
  51.         DiffRgn(wm->visRgn, wnd->contRgn, wm->visRgn);
  52.     }
  53.  
  54.     if (sysWDEF) {        /* Check for existence, just in case.  (Paranoia again.) */
  55.         hstate = HGetState(sysWDEF);
  56.         HLock(sysWDEF);
  57.         proc = (WDEFProcPtr)*sysWDEF;
  58.         ll = (*proc)(sel, wnd, msg, prm);                /* Call the real WDEF for all messages. */
  59.         HSetState(sysWDEF, hstate);
  60.     }
  61.  
  62.     if (msg == wCalcRgns) {                                /* If the message was to calc regions, */
  63.         srgn = wnd->strucRgn;
  64.         crgn = wnd->contRgn;
  65.         sleft = (*srgn)->rgnBBox.left;
  66.         cleft = (*crgn)->rgnBBox.left;
  67.         if (sleft + 6 < cleft) InsetRgn(srgn, 3, 3);    /* adjust the structRgn inward 3 pixels. */
  68.     }
  69.  
  70.     if (msg == wDraw) {
  71.         CopyRgn(wmVis, wm->visRgn);
  72.         DisposeRgn(wmVis);
  73.     }
  74.  
  75.     RestoreA4();
  76.     return(ll);
  77. }
  78.  
  79.  
  80.  
  81.